﻿using System;
using System.Web.UI;
using System.Data;
using BLL;
public partial class ModEmployee_EmployeeShowDetail : System.Web.UI.Page
{

    public string empCode = "";
    IBizSQL bizSQL = new BizSQL();
    protected void Page_Load(object sender, EventArgs e)
    {

        string account = "";

        // string strShowButton = "";
        int strDeptID = 0;
        if (Session["user"] != null)
        {
            User user = Session["user"] as User;
            account = user.Account;
            strDeptID = user.DepartemntID;
        }
        else
        {
            return;
        }
        if (Request.QueryString["EmpCode"] != null)
        {
            empCode = Request.QueryString["EmpCode"].ToString();
        }
        else
        {
            return;
        }
        if (!Page.IsPostBack)
        {
            if (empCode != "")//显示人事部门菜单
            {
                ShowButton(account, empCode);
            }
            else //使用获得的部门ID，来确定显示的按纽  
            {
                //ShowButton(strDeptID);
            }
        }
    }
    protected void ShowButton(string account, string empCode)
    {
        //根据account获取登录的 菜单
        hl0.NavigateUrl = "EmployeeDetail.aspx?EmpCode=" + empCode;
        hl0.Text = "员工资料";
        string strSQL = "select linkUrl from JimView_Account_Menu  WHERE State='Y' AND Account = '" + account + "' order by AbsIndex DESC";
        DataSet ds = bizSQL.ExecSQL2(strSQL);
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            string url = ds.Tables[0].Rows[i]["linkUrl"].ToString();

            if (url.Contains("EmpRewardsList"))
            {
                hl1.NavigateUrl = "EmpRewardsList.aspx?EmpCode=" + empCode;
                hl1.Text = "奖惩记录";
            }
            else if (url.Contains("EmpChangeList"))
            {
                hl2.NavigateUrl = "EmpChangeList.aspx?EmpCode=" + empCode;
                hl2.Text = "变动记录";
            }
            else if (url.Contains("TrainList"))
            {
                hl3.NavigateUrl = "../ModTrain/TrainList.aspx?EmpCode=" + empCode;
                hl3.Text = "培训信息";
            }
            else if (url.Contains("EmpInsuranceList"))
            {
                hl4.NavigateUrl = "EmpInsuranceList.aspx?EmpCode=" + empCode;
                hl4.Text = "社会保险";
            }
            else if (url.Contains("EmpPassedList"))
            {
                hl5.NavigateUrl = "EmpPassedList.aspx?EmpCode=" + empCode;
                hl5.Text = "转正信息";
            }
            else if (url.Contains("EmpLeaveList"))
            {
                hl6.NavigateUrl = "EmpLeaveList.aspx?EmpCode=" + empCode;
                hl6.Text = "离职记录";
            }
        }
    }
    //protected void ShowButton(string strDeptID)
    //{
    //    if (string.IsNullOrWhiteSpace(strDeptID))
    //        return;
    //    try
    //    {
    //        string strPropertie = new DepartmentBiz().GetPropertie(Int32.Parse(strDeptID));
    //            switch (strPropertie)
    //            {
    //                case "manager"://
    //                    strShowButton = "";
    //                    break;                   
    //                case "market"://
    //                    strShowButton = "";
    //                    break;
    //                case "sale"://
    //                    strShowButton = "<td style=\"width: 87px; height: 21px; background-image: url(../Images/page_button_long.gif);\" align=\"center\" valign=\"bottom\">&nbsp;<a href=\"../ModCustomer/CustomerList.aspx?ParamID=" + account + "&IDType=Personal\" target=\"ifrmMain\">客户列表</a></td>";
    //                    strShowButton += "<td style=\"width: 87px; height: 21px; background-image: url(../Images/page_button_long.gif);\" align=\"center\" valign=\"bottom\">&nbsp;<a href=\"../ModSale/OrderList.aspx?ParamID=" + account + "&IDType=Personal\" target=\"ifrmMain\">历史订单</a></td>";
    //                    break;
    //                case "finance"://财务
    //                    strShowButton = "";
    //                    break;
    //                case "stock"://采购
    //                    strShowButton = "";
    //                    break;
    //                case "transport"://物流/仓库
    //                    strShowButton = "";
    //                    break;
    //                case "service"://客户服务
    //                    strShowButton = "";
    //                    break;
    //                case "research"://研发
    //                    strShowButton = "";
    //                    break;
    //                case "produce"://生产
    //                    strShowButton = "";
    //                    break;
    //                case "admin"://行政
    //                case "human"://人事
    //                    strShowButton = "<td style=\"width: 87px; height: 21px; background-image: url(../Images/page_button_long.gif);\" align=\"center\" valign=\"bottom\">&nbsp;<a href=\"EmpRewardsList.aspx?EmpCode=" + empCode + "\" target=\"ifrmMain\">奖惩记录</a></td>";
    //                    strShowButton += "<td style=\"width: 87px; height: 21px; background-image: url(../Images/page_button_long.gif);\" align=\"center\" valign=\"bottom\">&nbsp;<a href=\"EmpChangeList.aspx?EmpCode=" + empCode + "\" target=\"ifrmMain\">变动记录</a></td>";
    //                    strShowButton += "<td style=\"width: 87px; height: 21px; background-image: url(../Images/page_button_long.gif);\" align=\"center\" valign=\"bottom\">&nbsp;<a href=\"../ModTrain/TrainList.aspx?EmpCode=" + empCode + "\" target=\"ifrmMain\">培训信息</a></td>";
    //                    strShowButton += "<td style=\"width: 87px; height: 21px; background-image: url(../Images/page_button_long.gif);\" align=\"center\" valign=\"bottom\">&nbsp;<a href=\"EmpLeaveList.aspx?EmpCode=" + empCode + "\" target=\"ifrmMain\">离职记录</a></td>";
    //                    break;
    //                case "IT"://
    //                    break;
    //                case "plan"://策划
    //                    strShowButton = "";
    //                    break;
    //                case "design"://设计
    //                    strShowButton = "";
    //                    break;
    //                default:
    //                    break;
    //            }
    //    }
    //    catch (Exception ex)
    //    {
    //        Response.Write("错误，错误原因：" + ex.Message);
    //    }


}
//cend

